/* Scripts needed on all or many pages.
 * Aaron Hudson
 * Random-Website Global JS
 */

function sizeLayout() { // Properly size the menu height and the content width to fit the device. 
	$jQuery(window).load(function() {
		window.alert("resizing");
		var divHeight = $('#content').height();
		divHeight += $('#footer').height();
		$("#menu").css("height",divHeight);				
		var divWidth = $('#container').width();
		divWidth -= $('#menu').width();
		divWidth -=1; // Oddly enough, it only works if you subtract a pixel. Haven't figured out why yet. Possibly padding? 
		$("#content").css("width",divWidth);
		$("#footer").css("width",divWidth);
	});
}

function detectRotation() { // Detect if the orientation of mobile devices changes, and adjust accordingly.
	$jQuery(window).load(function() {
	var supportsOrientationChange = "onorientationchange" in window, // Is onorientationchange a property of the window object? 
		orientationEvent = supportsOrientationChange ? "orientationchange" : "resize"; // orientationEvent is equal to orientationchange if boolean supportsOrientationChange is true, or resize if its false. Android will resize the screen on orientation flip, but doesn't have a orientation property, whereas iPhones wont resize, but has an orietnation property 

	window.addEventListener(orientationEvent, function() { // Event listener for orientation, which will resize layout on rotation. 
		sizeLayout();
	}, false);
	});
}